home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 March: Reference Library / Dev.CD Mar 96 RL / Dev.CD Mar 96 RL.toast / Technical Documentation / develop / develop Issue 25 / develop Issue 25 code / QD3D to QTVR / ArticleCode / Source / traps.h < prev   
Encoding:
Text File  |  1995-10-08  |  957 b   |  48 lines  |  [TEXT/MPCC]

  1. // Simple framework for Macintosh sample code
  2. //
  3. // Nick Thompson, DEVSUPPORT
  4. //
  5. // This file contains the trap detection related code code for the framework.
  6. // 
  7. // 9/16/94    nick    first cut
  8.  
  9. #include <Types.h>
  10. #include <Traps.h>
  11. #include <OSUtils.h>
  12. #include <GestaltEqu.h>
  13.  
  14. short myNumToolboxTraps(void);
  15. TrapType myGetTrapType(short theTrap);
  16.     
  17. short myNumToolboxTraps(void)
  18. {
  19.     if (NGetTrapAddress(_InitGraf, ToolTrap) == NGetTrapAddress(0xAA6E,ToolTrap))
  20.         return 0x0200;
  21.     else
  22.         return 0x0400;
  23. }
  24.  
  25. TrapType myGetTrapType(short theTrap)
  26. {
  27.     if ((theTrap & 0x0800) > 0)
  28.         return ToolTrap;
  29.     else
  30.         return OSTrap;
  31. }
  32.  
  33. Boolean    myTrapAvailable(short theTrap)
  34. {
  35.     TrapType tType;
  36.     Boolean isAvail;
  37.     
  38.     tType = myGetTrapType(theTrap);
  39.     if (tType == ToolTrap)
  40.         {
  41.             theTrap &= 0x07FF;
  42.             if (theTrap >= myNumToolboxTraps())
  43.                 theTrap = _Unimplemented;
  44.         }
  45.     
  46.     isAvail = NGetTrapAddress(theTrap, tType) != NGetTrapAddress(_Unimplemented, ToolTrap);
  47.     return isAvail;
  48. }